/*
 * Filename: g:\espidf_workspace\idf_S3_T-Watch\main\sources\app.h
 * Path: g:\espidf_workspace\idf_S3_T-Watch\main\sources
 * Created Date: Wednesday, June 18th 2025, 4:33:05 pm
 * Author: sss
 * 
 * Copyright (c) 2025 Your Company
 */

#ifndef __APP_H__
#define __APP_H__

#include "stdint.h"
#include "time.h"

/**
 * 音频状态
*/
typedef enum{
    SOUND_STATE_IDLE,//空闲状态
    SOUND_STATE_LISTENING,//监听状态
    SOUND_STATE_SPEAKING,//说话状态
    SOUND_STATE_RECORDING,//录音状态
    SOUND_STATE_PLAYING,//播放
} sound_state_t;

/**
 * 麦克风状态
*/
typedef enum{
    MIC_STATE_IDLE,//空闲状态
    MIC_STATE_RECORDING,//录音状态
} mic_state_t;

/**
 * 显示状态
*/
typedef enum{
    DISPLAY_STATE_IDLE,//空闲状态 黑屏
    DISPLAY_STATE_SHOW_HOMEPAGE,//显示主页
} display_state_t;


class APP {
public:
    static APP& getInstance(){
        static APP app;
        return app;
    };

    APP(const APP&) = delete;
    APP& operator=(const APP&) = delete;

    static time_t current_timestamp;
    static tm current_time;

    sound_state_t sound_state = SOUND_STATE_IDLE;
    mic_state_t mic_state = MIC_STATE_IDLE;
    display_state_t display_state = DISPLAY_STATE_IDLE;


    void Start();//启动APP
    void Reboot();//重启APP

    static void main_loop(void*);//循环
    static void main_longdelay_loop(void*);//循环



    void light_on_screen();//亮屏
    void light_off_screen();//灭屏


    void sr_start_listen();//语音识别
    void sr_stop_listen();


    void tts_chinese_say(const char* text);//说中文

    void record_sound();//录制pcm音频
    void play_sound(uint16_t* pcm);//播放pcm音频

private:
    APP();
    ~APP();
};

#endif